using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/**蹦床 */
public class Trampoline : MonoBehaviour
{
    public float jumpForce = 24.0f;

    private Animator _animator;
    private static readonly int Jump = Animator.StringToHash("jump");

    // Start is called before the first frame update
    void Start()
    {
        _animator = GetComponent<Animator>();
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    private void OnCollisionEnter2D(Collision2D other)
    {
        if (other.gameObject.CompareTag("Player"))
        {
            _animator.SetTrigger(Jump);
            other.gameObject.GetComponent<Rigidbody2D>().AddForce(new Vector2(0, jumpForce), ForceMode2D.Impulse);
        }
    }
}
